d={"学士":0, "硕士":1, "博士":2}

def degree_order( s ):
    t = s[1]
    return d[t]

names = [["YBX", "学士"], ["小明", "学士"], ["小红", "博士"], ["小方", "硕士"], ["小刚", "硕士"]]
print(names)
names.sort(key=degree_order)
print(names)

